#pragma once
#include "../Package/ZPackageBase.h"
#include "ZTcpReadHelper.h"

class ZTcpPackReactorMgr;

class ZTCPNETLIB ZTcpClientSocket : public QTcpSocket
{
	Q_OBJECT
public:
	ZTcpClientSocket(ZTcpPackReactorMgr* pReactorMgr);

public:
	bool Connect(const QString &hostName, quint16 port, int iWaitTimeMs);
	qint64 Send(const ZPackageBase& package);
	bool IsConnected();

protected slots:
	virtual void OnConnected() {}; 
	virtual void OnDisConnected() {}; 
	virtual void OnRecvMessage(); 
	virtual void OnError(QAbstractSocket::SocketError socketError) {};

protected:
	ZTcpPackReactorMgr* m_pReactorMgr;
	ZTcpReadHelper		m_readHelper;
};